package xyz.suancaiyu.chapter42.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.suancaiyu.chapter42.bean.ConfigBean;
import xyz.suancaiyu.chapter42.bean.User;

/**
 * 4.3.2 将配置文件的属性赋给实体类.
 *
 * @author puruidong
 * @version 2018/12/28 22:02
 */
@RestController
@EnableConfigurationProperties({ConfigBean.class, User.class})
public class LucyController {
    @Autowired
    ConfigBean configBean;

    @Autowired
    User user;


    @RequestMapping(value = "/lucy")
    public String lucy() {
        return configBean.getGreeting() + "," + configBean.getName() + "," + configBean.getUuid() + "," + configBean.getMax();
    }

    @RequestMapping(value = "/user")
    public String user() {
        return user.getName() + "," + user.getAge();
    }


}

